<%= render Admin::ContainerComponent.new do %>
  <%= render Admin::HeadingComponent.new(t(".title")) %>

  <%= render Admin::ContentComponent.new do %>
    <%= render Admin::Tables::TableComponent.new do |table| %>
      <% table.with_header t(".user") %>
      <% table.with_header t(".code") %>
      <% table.with_header t(".referrals_count") %>
      <% table.with_header do %>
        <span class="sr-only"><%= t(".view") %></span>
      <% end %>

      <% @users.each do |user| %>
        <% table.with_row do |row| %>
          <%= row.with_cell primary: true do %>
            <%= render Admin::LabeledAvatarComponent.new(user&.developer || user&.business, title: user.email, path: "mailto:#{user.email}") %>
          <% end %>

          <%= row.with_cell do %>
            <%= user.referral_code %>
          <% end %>

          <%= row.with_cell do %>
            <%= user.referrals_count %>
          <% end %>

          <% row.with_cell do %>
            <%= render Admin::BasicLinkComponent.new(t(".view"), admin_user_referrals_path(user)) %>
          <% end %>
        <% end %>
      <% end %>
    <% end %>

    <%== pagy_nav @pagy %>
  <% end %>
<% end %>
